/**
*      author: Y_Yao
*      created: 2025-02-08 17:49:17
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
unordered_map<int,int> h;
const int N = 2e5 + 7;
int q;

void solve()
{
    cin >> q;
    while(q--)
    {
        int o;
        cin >> o;
        if(o == 1)
        {
            int x;
            cin >> x;
            h[x]++;
        }
        else if(o == 2)
        {
            int x;
            cin >> x;
            h[x]--;
            if(h[x] == 0)
            {
                h.erase(x);
            }
        }
        else
        {
            cout << h.size() << endl;
        }
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}
